﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Upeu.Venta.Data.Entities;

namespace Upeu.Venta.Data.Mappings
{
    public class ProveedorMap : EntityTypeConfiguration<Proveedor>
    {
        public ProveedorMap()
        {
            //cambiar nombre table
            ToTable("Proveedores");

            //pk
            HasKey(t => t.Id);
            Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //campos
            Property(t => t.Nombre).IsOptional();            
            Property(t => t.Estado).IsRequired();

            //relacion 

            this.HasRequired(b => b.tipoproveedores)
                .WithMany(c => c.Proveedores)
                .HasForeignKey(b => b.Idtipoproveedor)
                .WillCascadeOnDelete(false);
        }
    }
}

